call config.bat

set KEYTOOL=start "" "%PATH_DEVECO%\jbr\bin\keytool.exe"

set PATH_P12_OHOS=%PATH_SIG_CENTER%\key\OpenHarmony.p12
set PATH_PROFILESIGNTOOL=%PATH_SIG_CENTER%\profilesigntool\provisionsigtool.jar
set PATH_TEMPLE_JSON=%PATH_SIG_CENTER%\profilesigntool\UnsgnedReleasedProfileTemplate.json
set PATH_PEM=%PATH_SIG_CENTER%\certificates\OpenHarmonyProfileRelease.pem

set APP_NAME=testcase
set PATH_CSR=%OUT_DIR%\%APP_NAME%.csr
set PATH_P12_TMP=%OUT_DIR%\%APP_NAME%.p12
set PATH_CER=%OUT_DIR%\%APP_NAME%.cer
set PATH_p7b=%OUT_DIR%\SgnedReleasedProfileTemplate.p7b


::p12
%KEYTOOL% -genkeypair -alias "%APP_NAME%" -keyalg EC -sigalg SHA256withECDSA -dname "C=CN,O=HUAWEI,OU=HUAWEI IDE,CN=%APP_NAME%"  -keystore %PATH_P12_TMP% -storetype pkcs12 -validity 9125 -storepass %passwd% -keypass %passwd%

timeout /T 1

::CSR
%KEYTOOL% -certreq -alias "%APP_NAME%" -keystore %PATH_P12_TMP% -storepass %passwd% -keypass %passwd% -storetype pkcs12 -file %PATH_CSR%

timeout /T 1

::签名
%KEYTOOL% -gencert -alias "OpenHarmony Application CA" -infile %PATH_CSR% -outfile %PATH_CER% -keystore %PATH_P12_OHOS% -sigalg SHA256withECDSA -storepass 123456 -ext KeyUsage:"critial=digitalSignature" -validity 3650 -rfc

timeout /T 1

java -jar %PATH_PROFILESIGNTOOL% sign --in %PATH_TEMPLE_JSON% --out %PATH_p7b% --keystore %PATH_P12_OHOS% --storepass 123456  --alias "OpenHarmony Application Profile Release"  --sigAlg SHA256withECDSA --cert %PATH_PEM% --validity 365 --developer-id ohosdeveloper --bundle-name %NAME_BUNDLE% --distribution-certificate %PATH_CER%

pause